fix(security): escape codegen strings and redact diagnostic body#930
fix(security): escape codegen strings and redact diagnostic body#930
Conversation
1. candidateToJs: escape single quotes in site, name, domain, and arg name/type fields to prevent syntax errors in generated JS adapters. Previously only description and help fields were escaped. 2. diagnostic: pass network request body through redactText() to prevent sensitive data (JWT, bearer tokens) from leaking into repair context. responseBody/responsePreview already used sanitizeCapturedValue which calls redactText, but the body field only had truncation.
|
Reviewed the diff against local code. The fix correctly addresses both issues:
One minor suggestion: consider adding a unit test that feeds a candidate with single quotes in |
Summary
Fixes two bugs identified during post-migration first-principles review:
site,name,domain, and argname/typefields were written into generated JS adapter files without escaping single quotes. If any of these contained', the generated adapter would have a syntax error. Now all string literals in codegen use.replace(/'/g, "\\'")redactNetworkRequesttruncated thebodyfield but did not pass it throughredactText(), meaning JWTs or bearer tokens in response bodies could leak into AI repair context.responseBodyandresponsePreviewalready usedsanitizeCapturedValue→redactText, butbodywas missedTest plan
src/generate-verified.test.ts— 28 tests passedsrc/diagnostic.test.ts— 15 tests passed